package com.tianqu.tms.www.car.action;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.entity.Codes;
import com.tianqu.tms.www.car.viewhelper.CarImportExportGateViewHelper;

/**
 * 进出口监控页
 *
 */
public class CarImportExportMonitoringAction extends TmsAction {
	
	private Logger logger = Logger.getLogger(CarImportExportMonitoringAction.class);


	@SuppressWarnings("unchecked")
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		if (uc != null) {
			uc.clear();			
		}

		CarImportExportGateViewHelper view = new CarImportExportGateViewHelper();
		Codes code = Codes.getInstance();
		Date date = new Date();//当前日期
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");//格式化对象
		List list = code.getCodeslistByItemId(Codes.GATEWAY_TYPE);
		view.setGateTypeListA(list);
		view.setGateTypeListB(list);
		view.setGateId1("0");
		view.setGateId2("0");
		view.setNowDate(sdf.format(date));

		uc.setAttribute(TmsConstants.VIEWHELP, view);
		request.setAttribute(TmsConstants.VIEWHELP, view);		
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}
}
